import { Injectable } from '@nestjs/common';
import { MailerService } from '@nestjs-modules/mailer';

interface SendEmailParams {
  to: string;
  subject: string;
  context: {
    nickname: string;
    description: string;
    content: string;
  };
}

@Injectable()
export class EmailService {
  constructor(private readonly mailerService: MailerService) {}
  async sendEmail(params: SendEmailParams) {
    const { to, context, subject } = params;
    return await this.mailerService.sendMail({
      to,
      subject,
      template: 'email-code',
      context,
    });
  }
}
